home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
48971
/
48971.xpi
/
content
/
gview.js
< prev
next >
Wrap
Text File
|
2010-02-10
|
2KB
|
31 lines
var gview = {
go : function(url) {
var _valid = /.*(:\/\/.+\/.*\.(?:pdf|ps|ppt|doc|docx|tif|tiff)).*/i.test(url),
_open = function(url){
var _proto, _special;
// For Quick View in google.com and google.com.hk
if ((_special = /^https?:\/\/[^\.]+\.google\.com?\.?[^\/]*\/url\?.*url=([^&]+)/i.exec(url)
|| /^https?:\/\/[^\.]+\.google\.com?\.?[^\/]*\/url\?.*q=([^&]+)/i.exec(url))
&& (url = decodeURIComponent(_special[1])) && /\/\/docs\.google\.com\//i.test(url)) {
_special = /cache:[^:]+:([^\+]+)/i.exec(url);
url = url.replace(/^https?/, (_special[1].indexOf('https') === 0) ? 'https' : 'http');
} else {
url = (_special = /^https?:\/\/(?:docs\.google\.com\/g?viewe?r?|www\.google\.com?\.?[^\/]*\/url)\?.*url=([^&]*)/i.exec(url))
? _special[1]
: encodeURIComponent(url);
_proto = /^([^%]*)%3A/i.exec(url);
url = (!_proto || 'http'==_proto[1] ? 'http' : 'https') + '://docs.google.com/viewer?url=' + url;
}
var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(''),
newWin = prefManager.getBoolPref('extensions.gview.openboolpref', false);
if (newWin)
window.open(url, '', "width=780,height=450,location=yes,resizable=yes,scrollbars=yes,status=yes")
else
gBrowser.selectedTab = gBrowser.addTab(url)
};
if (_valid || window.confirm('Only PDF documents, PowerPoint presentations, and TIFF files are supported!\nStill go ahead?'))
_open(url)
}
}